MOHAA scripting language, Appendix A
Commands
When you know how to script, its time to start using the commands
that you can invoke from the scripting language. This document is
a list of commands paired with descriptions and other explanations
of how best to use them. It is by no means all of the commands,
just the most common and / or the ones that needs to be explained
the most. For a complete ( but short ) definition of ALL commands,
see the file g_allclasses.html ( for Allied Assault ) and MOH_GameClasses.html ( for Spearhead ).
It would be a good idea to cross-read this
document ( about classes ) as a refrerence when reading this
document.
Table of contents
Definitions and syntax
The format used to describe the commands is like this:
| Command: |
Name of the command. |
| Syntax: |
What class this command is sent to, and any parameters it
supports is described here. |
| Example: |
A code snippet exemplifying how to use the command. |
| Description: |
A textual description of the command. When best to use it.
When not to use it. Dark secrets and government conspiracy linked
to the command. |
| Comment: |
Any details not fitting into the above will be fitted into
this space ( if any ). |
The 'Syntax' section is declared like this:
class_name name_of_command ( parameter_1_type, parameter_1_descriptive
name, [optional_parameter_2_type, optional_parameter_2_descriptive
name] ).
Example: <Entity> cansee( Entity entity, [ Float
fov ], [ Float vision_distance ] ).
Example explanation: The class 'Entity' supports a command
named 'cansee'. This command requires a parameter of the class
'Entity', and you may also supply the two 'Float' parameters fov
& vision_distance. Any place where a certain class is required,
any class inheriting from that class will also work just as well.
In short:
A commands parameter list is written within parentheses - ( ).
An optional command is written within 'square' parentheses - [
].
Object manipulation
Existence
| Command: |
hide |
| Syntax: |
<Entity> hide |
| Example: |
$document_to_steal hide
|
| Description: |
This command hides an object so that it is invisible to the
player. The object still exists... its just invisible. If it
is already invisible, nothing happens. |
| Command: |
show |
| Syntax: |
<Entity> show |
| Example: |
$document_to_steal show
|
| Description: |
This command shows an object so that it is visible to the
player. If it was already shown... nothing really happens. |
| Command: |
remove |
| Syntax: |
<Entity> remove |
| Example: |
$document_to_steal remove
|
| Description: |
This command removes an object so that it no longer exists
in the game. |
Rotation
| Command: |
rotateX, rotateY, rotateZ |
| Syntax: |
<ScriptSlave> rotateX ( Float angular_velocity ) |
| Example: |
$fan rotateX 1.5
|
| Description: |
Rotate about the X ( or Y or Z ) axis at the specified angular
velocity. The angular_velocity represents the speed to rotate
the object. |
| Command: |
rotateXdown, rotateYdown, rotateZdown |
| Syntax: |
<ScriptSlave> rotateXdown ( Float angle ) |
| Example: |
$trapdoor rotateXdown 45.0
|
| Description: |
Rotate the X ( or Y or Z ) down by the specified angle. The
angle represents the angle to rotate the object.
|
| Command: |
rotateXup, rotateYup, rotateZup |
| Syntax: |
<ScriptSlave> rotateXup ( Float angle ) |
| Example: |
$trapdoor rotateXup 45.0
|
| Description: |
Rotate the X ( or Y or Z ) up by the specified angle. The
angle parameter represents the angle to rotate the object.
|
| Command: |
rotateXdownto, rotateYdownto, rotateZdownto |
| Syntax: |
<ScriptSlave> rotateXdownto ( Float angle ) |
| Example: |
$trapdoor rotateXdownto 45.0
|
| Description: |
Rotate the X ( or Y or Z ) down to angle. The angle parameter
represents the angle to rotate the object.
|
| Command: |
rotateXupto, rotateYupto, rotateZupto |
| Syntax: |
<ScriptSlave> rotateXdownto ( Float angle ) |
| Example: |
$trapdoor rotateXdownto 45.0
|
| Description: |
Rotate the X ( or Y or Z ) up to angle. The angle parameter
represents the angle to rotate the object.
|
Movement
| Command: |
move, waitmove |
| Syntax: |
<ScriptSlave> move |
| Example: |
$elevator moveto $waypoint_down
$elevator move
|
| Description: |
Move the script slave. This command executes the previous
movement commands sent to a ScriptSlave ( the class of a script_object
). The waitmove command also waits for the move to complete
before continuing execution.
|
| Command: |
moveto |
| Syntax: |
<ScriptSlave> moveto ( Entity destination ) |
| Example: |
$elevator moveto $top_floor
|
| Description: |
Move to the specified entity.
|
| Command: |
moveto |
| Syntax: |
<Actor> moveto ( String anim, String dest ) |
| Example: |
$evil_one moveto "anim/my_animation" "there"
|
| Description: |
Specify the location to move the actor to, with the animation
anim used.
|
| Command: |
moveup, movedown, moveForward,
moveBackward, moveLeft, moveRight, moveEast,
moveNorth, moveSouth, moveWest |
| Syntax: |
<ScriptSlave> moveup ( Float distance ) |
| Example: |
$elevator moveup 64
|
| Description: |
Move the specified distance ( Measured in world units ).
|
Object status tests
| Command: |
isAlive |
| Syntax: |
<ScriptThread> isAlive |
| Example: |
if !(isAlive $vip_player) { teamwin axis }
|
| Description: |
This command checks to see if something is alive. If it is,
1 is returned else 0 is returned ( if it is "dead" that is
).
The definition of life ( in MOH ) is to have more than 0 in
health.
|
| Command: |
isTouching |
| Syntax: |
<Entity> isTouching ( Entity entity ) |
| Example: |
if ! ( $player[local.index] isTouching $it ) { teamwin axis }
|
| Description: |
This command checks to see if something is touching the object.
If it is, 1 is returned else 0 is returned. ( Not sure about
his commands usage and function, tell me more! ).
|
| Command: |
sighttrace |
| Syntax: |
<ScriptThread> sighttrace ( Vector start, Vector end,
[ Integer pass_entities ], [ Vector mins ], [ Vector maxs ]
) |
| Example: |
sighttrace ( 20 30 3045 ) ( 0 0 0 ) 1
|
| Description: |
Performs a trace line from the start to the end, returns
0 if something was hit and 1 otherwise.
The pass_entities sets the number of entity bounding boxes
that are assumed to be 'invisible'.
mins and maxs set the bounding box within the sighttrace.
It is performed to save CPU usage. (See also setsize command).
|
| Comment: |
The same command is found in the Entity class. |
Sound
Sound is played on a distinct channel, here is a list of the available
channels:
| Id |
Name |
Description |
| 0 |
auto |
This is considered the lowest audio channel priority. It always
plays if possible (hardware audio channel available) and they
don't override previously played sounds. If no channels are
available, the sound will just not play. This is best used for
things that do not have a particular entity or character related
to them (like bullet hit sounds), or are not overly important
sound (like shell casing landing sounds or footsteps). |
| 1 |
body |
These are sounds made by a characters body. These include
sounds like impact sounds (from falling & landing hard)
and equipment movement jingles. |
| 2 |
item |
These are sounds made by items on a character, or that represent
some sort of item related sound. These would include sounds
made by any misc items carried by a character like papers or
binorulars, but could also be used as a second weapon sound
channel if it is required for a weapon to play two different
sounds at the same time. This is also the channel that should
be used for weapon reload sound to prevent them from cutting
off long firing sounds. |
| 3 |
weaponidle |
Is for constant sound made by weapons or possibly the character
itself. An example from Quake3 would be the rail gun hum, but
I can't think of any examples from MoH, exept a low mumbling
of the player commenting on how mush he/she loves his/her gun.. |
| 4 |
voice |
These are vocal sounds made by a character such as pain, death,
and yelling during combat. This is effectively a lower priority
dialog channel for general use throughout the majority of the
game. |
| 5 |
local |
This plays a sound that is considered to be "local" to the
player. Meaning, it does not do 3D spatialization on the sound.
It does adjust the volume of the sound according to distance
though. This is best used for playing sounds that should sound
omni-directional like rain or lightning. |
| 6 |
weapon |
These are the sound that are made by the characters' weapons.
These include the firing sounds, but not reloading sounds. |
| 7 |
dialog_secondary |
This is a secondary backup dialog channel. Good for use with
lower priority dialog such as idle chatter between characters,
as it's considered to be lower priority than regular dialog.
This should only include spoken dialog that will have subtitle
text. |
| 8 |
dialog |
This is the primary sound channel for playing character dialog.
This should only include spoken dialog that will have subtitle
text. |
| 9 |
menu |
This is the sound channel for menu sounds to play on. |
| Command: |
playsound |
| Syntax: |
<Entity> playsound ( String soundName, [ Integer channel
], [ Float volume ], [ Float min_distance ], [ Float pitch ]
)
|
| Example: |
$radio playsound "emergency_broadcast" 7
|
| Description: |
Plays a sound coming from this entity. Default channel is
body ( 1 ).
|
| Command: |
stopsound |
| Syntax: |
<Entity> stopsound ( [ Integer channel ] ) |
| Example: |
$radio stopsound 7
|
| Description: |
Stops the current sound on the specified channel. Default
channel is body ( 1 ).
|
| Command: |
loopsound |
| Syntax: |
<Entity> loopsound ( String soundName, [ Float volume
], [ String minimum_distance ] ) |
| Example: |
$radio loopsound "ether_static"
|
| Description: |
Play a looped-sound with a certain volume and minimum_distance
which is attached to the current entity.
|
| Command: |
stoploopsound |
| Syntax: |
<Entity> stoploopsound |
| Example: |
$radio stoploopsound
|
| Description: |
Stop the looped-sound on this entity.
|
Text printing
| Command: |
print, println |
| Syntax: |
<ScriptThread> print ( String text ) |
| Example: |
print "It came from the script ( desert? )!"
|
| Description: |
Prints a message in the consol. The println version is followed
by a line break.
|
| Command: |
iprintln, iprintlnbold |
| Syntax: |
<ScriptThread> iprintln ( String text ) |
| Example: |
iprintln "It came from the script ( desert? )!"
|
| Description: |
Prints a message on the left side of the screen in yellow
( no clicking sound ) followed by a line break. The bold version
uses the same font, but in white and clicking.
|
| Command: |
iprintln_noloc, iprintlnbold_noloc |
| Syntax: |
<ScriptThread> iprintln_noloc ( String text ) |
| Example: |
iprintln_noloc "Elvis has left the building!"
|
| Description: |
Prints a message on the left side of the screen in white
( with a clicking sound ) followed by a line break. Bold version
uses a bold font.
|
| Command: |
locprint |
| Syntax: |
<ScriptThread> locprint ( Integer X_offset, Integer
Y_offset, String text ) |
| Example: |
locprint 30, 100, "Here I am!"
|
| Description: |
Prints a message in the specified X-Y location of all player's
screens.
|
Mathematic
| Command: |
abs |
| Syntax: |
<ScriptThread> abs ( Float argument ) |
| Example: |
abs -23.656
|
| Description: |
Returns the absolute value of the parameter. abs 15.3 returns
15.3. abs -2 returns 2. abs -5.999 returns 5.999.
|
| Command: |
randomfloat |
| Syntax: |
<ScriptThread> randomfloat ( Float max ) |
| Example: |
randomfloat 14.9
|
| Description: |
Returns a random number between 0 and 'max'.
|
| Command: |
randomint |
| Syntax: |
<ScriptThread> randomint ( Integer max ) |
| Example: |
randomint 10
|
| Description: |
Returns a random number between 0 and 'max'.
|
Command combinations
Elevator
An elevator...
|